package com.lujieni.springboothutool.controller;

import cn.hutool.core.util.URLUtil;
import com.lujieni.springboothutool.utils.DataDesensitizationUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author：Jie Ni
 * @Date: 2025/6/18 10:35
 * @Description:
 */
@RestController
public class DataDesensitizationController {

    /**
     *  对input进行aes加密,返回的结果进行编码
     *  将字符串中的 +号转为%2B
     *  @param input
     *  @return
     */
    @GetMapping("/encrypt")
    public String encrypt(String input) {
        String encrypt = DataDesensitizationUtils.encrypt(input);
        // 编码将"+"->%2B "="->%3D
        return URLUtil.encodeAll(encrypt);
    }

    /**
     * 浏览器中:2Pi%2BVzjs%2BmtHaxEe8gdXHQDmND8Q0KSKHIOfzSglJig%3D
     * 入参input已经自动变为:2Pi+Vzjs+mtHaxEe8gdXHQDmND8Q0KSKHIOfzSglJig=
     * @param input
     * @return
     */
    @GetMapping("/decrypt")
    public String decrypt(@RequestParam String input) {
        return DataDesensitizationUtils.decrypt(input);
    }



}
